package com.yaolong.api.configuration;
import com.yaolong.api.task.MapperHotRefreshTask;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSessionFactory;

import java.nio.file.Path;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
 * @author yaolong
 * @version V1.0.0
 * @program opms
 * @description 热更新
 * @create 2023-01-30 11:09
 **/
@Slf4j
public class HotRefresh {
    private static final ExecutorService EXECUTORSERVICE = Executors.newCachedThreadPool();

    public HotRefresh(SqlSessionFactory sqlSessionFactory, Path path) {
        Configuration configuration = sqlSessionFactory.getConfiguration();
        MapperHotRefreshTask refreshTask = new MapperHotRefreshTask(configuration, path);
        EXECUTORSERVICE.submit(refreshTask);
    }

}
